package com.qnvip.sbd.mybatis.sqlprovider;


import com.qnvip.sbd.mybatis.annotation.Database;

public class SqlProviderHelper {

	public static String getTable(Object object) {
		Class<?> clazz = object.getClass();
		return getTable(clazz);
	}
	
	public static String getTable(Class<?> clazz) {
		if(clazz.isAnnotationPresent(Database.class)) {
			Database db = (Database) clazz.getAnnotation(Database.class);
			return db.tableName();
		} else {
			String table = clazz.getName();
			if (table.contains(".")) {
				table = table.substring(table.lastIndexOf(".") + 1);
			}
			return table;
		}
	}
}
